<?php

use yii\db\Migration;

/**
 * Handles the creation of table `product`.
 */
class m180915_042944_create_product_table extends Migration
{
    public $tableName = '{{%product}}';

    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable($this->tableName, [
            'id' => $this->primaryKey(),
            'goods_sn' => $this->char(4)->notNull()->comment('产品识别码'),
            'price' => $this->decimal(5,2)->notNull()->defaultValue(0.00)->comment('红包金额'),
            'code' => $this->string(255)->notNull()->defaultValue('')->comment('3位码前缀'),
            'security_sn' => $this->char(8)->notNull()->defaultValue('')->comment('防伪码'),
            'product_name' => $this->string(255)->notNull()->comment('产品名称'),
            'created_at' => $this->integer(11)->notNull()->comment('创建时间'),
            'updated_at' => $this->integer(12)->notNull()->comment('修改时间'),
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable($this->tableName);
    }
}
